package com.atiguigu.rabbitmq.seven;

import com.atiguigu.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.concurrent.TimeoutException;

public class TopicLogs {
    public static final String EXCHANGE_NAME = "topic_logs";
    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitMqUtils.getChannel();
        //声明交换机名、topic类型
        channel.exchangeDeclare(EXCHANGE_NAME, BuiltinExchangeType.TOPIC);
        Map<String,String> bindingMap=new HashMap<>();
        bindingMap.put("quck.orange.rabbit","Q1Q2接收");
        bindingMap.put("lazy.orange.fox","Q1Q2接收");
        bindingMap.put("quck.orange.fox","Q1接收");
        bindingMap.put("lazy.gtry.fox","Q2接收");
        bindingMap.put("quck.browm.ra","无人接收");
        bindingMap.put("lazy.fox.rabbit","Q2接收一次");
        bindingMap.put("quck.orange.rabbit.fox","4个单词，无人接手");
        bindingMap.put("lazy.orange.rabbit.fox","4个单词，Q2接手");
        for(Map.Entry<String, String> entries:bindingMap.entrySet()){
            String rountingkey = entries.getKey();
            String message = entries.getValue();
            channel.basicPublish(EXCHANGE_NAME,rountingkey,null,message.getBytes("UTF-8"));
            System.out.println("生产者发消息："+message);
        }


    }
}
